#ifndef LGE_VECTOR2_H
#define LGE_VECTOR2_H

template<typename T>
struct Vector2
{
	T mX;
	T mY;

	Vector2(T x=0, T y=0)
	: mX(x), mY(y)
	{
	}

	Vector2 & operator+=(const Vector2 & b)
	{
		mX += b.mX;
		mY += b.mY;
	}

	Vector2 & operator-=(const Vector2 & b)
	{
		mX -= b.mX;
		mY -= b.mY;
	}
};

/**
  * \brief Addition of 2 vectors
  */
template<typename T>
inline Vector2<T> operator+(const Vector2<T> & a, const Vector2<T> & b)
{
	return Vector2<T>(a.mX + b.mX, 
				      a.mY + b.mY);
}

/**
  * \brief Subtraction of 2 vectors
  */
template<typename T>
inline Vector2<T> operator-(const Vector2<T> & a, const Vector2<T> & b)
{
	return Vector2<T>(a.mX - b.mX, 
				      a.mY - b.mY);
}

/**
  * \brief Dot product of 2 vectors
  */
template<typename T>
inline T operator*(const Vector2<T> & a, const Vector2<T> & b)
{
	return a.mX * b.mX + a.mY * b.mY;
}

/**
  * \brief Scalar multiplication
  */
template<typename T>
inline Vector2<T> operator*(const Vector2<T> & a, T scalar)
{
	return Vector2<T>(a.mX * scalar, 
				      a.mY * scalar);
}

/**
  * \brief Scalar multiplication
  */
template<typename T>
inline Vector2<T> operator*(T scalar, const Vector2<T> & b)
{
	return b * scalar;
}

#endif
